#

SRC=main.c
BASE=$(shell pwd)
BUILD=$(BASE)/.build
OBJ=.build/$(SRC).hex

# Nano clone
MACH=arduino:avr:nano:cpu=atmega328
PORT=/dev/ttyUSB1
CPU=atmega328p
BAUD=57600
PROTO=arduino

HARD=/usr/share/arduino/hardware
TOOLS=/usr/share/arduino/tools

#

all:
	rm -rf .build; mkdir .build
	-mv -f ds3231-set.c ds3231-set.foo
	-mv -f main.foo main.c
	arduino-builder -hardware $(HARD) -tools $(TOOLS) -fqbn $(MACH) \
	-build-path $(BUILD) -compile $(SRC)

upload:
	avrdude -D -V -F -C /etc/avrdude.conf -c $(PROTO) \
	-p $(CPU) -P $(PORT) -b $(BAUD) -U flash:w:$(OBJ)

clean:
	rm -rf $(BUILD)
	mkdir $(BUILD)

###
